package client.comm.commlib.widget

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.LinearLayout
import androidx.databinding.DataBindingUtil
import client.comm.commlib.R
import client.comm.commlib.databinding.LayoutStepperitemBinding
import client.comm.commlib.network.data.WlDetail

class StepperView @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : LinearLayout(context, attrs, defStyleAttr) {

    init {
        orientation = VERTICAL
    }

    fun setBBB(list: List<WlDetail.Context>) {
        removeAllViews()
        for ((ii, index) in list.withIndex()) {
            DataBindingUtil.inflate<LayoutStepperitemBinding>(
                LayoutInflater.from(context),
                R.layout.layout_stepperitem,
                this,
                false
            ).apply {
                bean = index
                if (ii == 0) {
                    isSelect = true
                    isTop = true
                } else {
                    isTop = false
                    isSelect = false
                }
                if (ii == list.size - 1) {
                    isBottom = true
                } else {
                    isBottom = false
                }
                addView(root)
            }

        }
    }
}